#include <iostream>
#include <future>
#include <thread>
#include <memory>


int Add(int n1, int n2)
{
    return n1 + n2;
}

int main()
{
    //封装任务， 类似于functional
    auto task = std::make_shared<std::packaged_task<int(int, int)>>(Add);
    //获取future对象
    std::future<int> ret = task->get_future();

    std::thread t1([task](){
        (*task)(11, 22);
    });

    //获取结果
    std::cout<< ret.get() <<std::endl;
    t1.join();
    return 0;
}